<template>
	<view class="container">
		<uni-forms ref="form" :rules="{}">
			<uni-forms-item label="" name="">
				<uni-easyinput v-model="user.telephone" placeholder="请输入用户电话号码" />
			</uni-forms-item>
			<uni-forms-item label="" name="">
				<uni-easyinput v-model="user.password" type="password" placeholder="请输入用户密码" />
			</uni-forms-item>
			<uni-forms-item label="" name="">
				<button type="primary" @click="register">注册</button>
			</uni-forms-item>
		</uni-forms>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user:{
					telephone:"",
					password:""
				}
			}
		},
		methods: {
register(){
	if(this.user.password==""||this.user.telephone==""){
		uni.showToast({
			title:'电话号码或密码不能为空',
			icon:'none'
		})
		return false
	}
	
	uni.request({
		url: 'http://localhost:8090/foodapp/user/register',
		method: 'POST',
		data: this.user,
		success: res => {
			if(res.data.success){
				uni.navigateTo({
					url:'../login/login'
				})
			}
		},
		fail: (err) => {
			console.log(err);
		},
		complete: (err) => {
			uni.showToast({
				title: '注册的电话号码重复',
				icon:'none'
			});
		}
	});
}
		},
		onLoad: () => {
		
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
